home *** CD-ROM | disk | FTP | other *** search
/ Graphics Plus / Graphics Plus.iso / msdos / plotting / pcgplots / gptmain.cpp < prev    next >
C/C++ Source or Header  |  1992-04-24  |  3KB  |  111 lines

  1. // GPtMain - main for program
  2. // copyright 1992 Pittsburgh Supercomputing Center
  3. #include "gpt.h"
  4. #include "new.h"
  5. // Multiple Document "main"
  6.  
  7. // Application class statics
  8. HANDLE Appl::hInstance          = 0;
  9. HANDLE Appl::hPrevInstance      = 0;
  10. int Appl::nCmdShow              = 0;
  11. LPSTR Appl::CmdParam             = NULL;
  12. HWND Appl::hWndClient           = NULL;
  13. HWND Appl::hWndFrame            = NULL;
  14. FrameWindowPt Appl::theFrame    = NULL;
  15. void newFail()
  16.     {
  17.     int i=1;
  18.     }
  19. // Turn off warning: Parameter 'lpszCmdLine' is never used in function WinMain(unsigned int,unsigned int,char far*,int)
  20. #pragma argsused
  21.  
  22. // Turn off warning aus- identifier MainWnd assigned value that is never used
  23. #pragma option -w-aus
  24.  
  25. int PASCAL WinMain( HANDLE hInstance, HANDLE hPrevInstance, LPSTR lpszCmdLine,
  26.                           int nCmdShow )
  27.     {
  28.     set_new_handler(newFail);
  29.     Appl::hInstance     = hInstance;
  30.     Appl::hPrevInstance = hPrevInstance;
  31.     Appl::nCmdShow      = nCmdShow;
  32.     Appl::CmdParam      = new char[lstrlen(lpszCmdLine) + 1];
  33.     lstrcpy((LPSTR)Appl::CmdParam,lpszCmdLine);
  34.     if ( ! Appl::hPrevInstance )
  35.         {
  36.         FrameWindow::Register();
  37.         CGMWindow::Register();
  38.         WMetaWindow::Register();
  39.         }
  40.     FrameWindow::LoadAccelerators(Appl::hInstance);
  41.     FrameWindow::LoadMenu(Appl::hInstance);
  42.     CGMWindow::LoadMenu(Appl::hInstance);
  43.     //CGMWindow::LoadAccelerators(Appl::hInstance);
  44.     WMetaWindow::LoadMenu(Appl::hInstance);
  45.     Appl::theFrame =  new FrameWindow;            // fire constructor
  46.  
  47.     int stat =  Appl::theFrame->MessageLoop();   // and process messages
  48.     delete Appl::theFrame;
  49.     if (Appl::CmdParam)    delete []Appl::CmdParam;
  50.     return stat;
  51.     }
  52. // ********* WndProc
  53. long FAR PASCAL _export WndProc( HWND hWnd, WORD iMessage,
  54.                  WORD wParam, LONG lParam )
  55.     {
  56.     // Pointer to the (C++ object that is the) window.
  57.     Window *pWindow = GetPointer( hWnd );  // invalid value if WM_CREATE not
  58.                       // yet processed
  59.     if ( pWindow == 0 )
  60.         {
  61.         if ( iMessage == WM_CREATE )
  62.             {
  63.             LPCREATESTRUCT lpcs;
  64.             lpcs = (LPCREATESTRUCT) lParam;
  65.             pWindow = (Window *) lpcs->lpCreateParams;
  66.  
  67.             // Store a pointer to this object in the window's extra bytes;
  68.             SetPointer( hWnd, pWindow );
  69.             // Now let the object perform whatever initialization it
  70.             // needs for WM_CREATE in its own WndProc.
  71.             return pWindow->WndProc(hWnd, iMessage, wParam, lParam );
  72.             }
  73.         else
  74.             return DefFrameProc( hWnd, Appl::hWndClient,
  75.                                 iMessage, wParam, lParam );
  76.         }
  77.     else
  78.         return pWindow->WndProc( hWnd, iMessage, wParam, lParam );
  79.     }
  80.  
  81. // ***** gptWndProc
  82. long FAR PASCAL _export gptWndProc( HWND hWnd, WORD iMessage,
  83.                  WORD wParam, LONG lParam )
  84.     {
  85.     // Pointer to the (C++ object that is the) window.
  86.     Window *pWindow = GetPointer( hWnd );  // invalid value if WM_CREATE not
  87.                       // yet processed
  88.     if ( pWindow == 0 )
  89.         {
  90.         if ( iMessage == WM_CREATE )
  91.             {
  92.             LPCREATESTRUCT lpcs;
  93.             LPMDICREATESTRUCT lpMDIcs;
  94.             lpcs = (LPCREATESTRUCT) lParam;
  95.             lpMDIcs = (LPMDICREATESTRUCT)lpcs->lpCreateParams;
  96.             //pWindow = (Window *) lpMDIcs->lParam;
  97.             pWindow = (Window *)GetObjectPt(lpMDIcs->lParam );
  98.             // Store a pointer to this object in the window's extra bytes;
  99.             SetPointer( hWnd, pWindow );
  100.             // Now let the object perform whatever initialization it
  101.             // needs for WM_CREATE in its own WndProc.
  102.             return pWindow->WndProc(hWnd, iMessage, wParam, lParam );
  103.             }
  104.         else
  105.             return DefMDIChildProc( hWnd, iMessage, wParam, lParam );
  106.         }
  107.     else
  108.         return pWindow->WndProc( hWnd, iMessage, wParam, lParam );
  109.     }
  110.  
  111.